#!/usr/bin/perl

sub make_data_file
{
	local($IN_FILE_NAME, $OUT_FILE_NAME) = @_;
print "aaaa\n";
	open(FILE, "<$IN_FILE_NAME");
	
	open(OUT_FILE, ">$OUT_FILE_NAME");

	while( $line = <FILE> ) {
		chop $line;
		$line =~ tr/		/	/;

		@val = split ' ', $line;

		@chk_val = split '\=', $val[1];
		$is_cmt = substr $val[0], 0, 1;

		if( ($chk_val[0] eq 'SRVGRP') &&
			($is_cmt ne '#') 
		) {
			$SRVGRP 	= $chk_val[1];
			$SERVERNAME = $val[0];
print "---->$val[0] : $val[1] $chk_val[0] ($is_cmt)<\n";
			if( ($SERVERNAME eq 'WSL') 		||
				($SERVERNAME eq 'DMADM') 		|| 
				($SERVERNAME eq 'GWADM')  	||
				($SERVERNAME eq 'GWTDOMAIN') ) {
				next;
			}

			@chk_val 	= split '\=', $val[2];
			$SRVID 		= $chk_val[1];

			@chk_val 	= split '\=', $val[5];
			$RQADDR 	= $chk_val[1];
			$str_len	= length $RQADDR;
			$RQADDR 	= substr $RQADDR, 1, $str_len - 2;

			@chk_val 	= split '\=', $val[3];
			$MIN 		= $chk_val[1];

			@chk_val 	= split '\=', $val[4];
			$MAX 		= $chk_val[1];
			
			$line = <FILE>;
			chop $line;
			@val = split '\=', $line;

			$CLOPT 		= $val[1];

print "------------>SRVGRP:$SRVGRP<\n";
print "------------>SRVID:$SRVID<\n";
print "------------>SERVERNAME:$SERVERNAME<\n";
print "------------>RQADDR:$RQADDR<\n";
print "------------>MIN:$MIN<\n";
print "------------>MAX:$MAX<\n";
print "------------>CLOPT:$CLOPT<\n";
print OUT_FILE "AC;";
print OUT_FILE "$SRVGRP;";
print OUT_FILE "$SRVID;";
print OUT_FILE "$SERVERNAME;";
print OUT_FILE "$RQADDR;";
print OUT_FILE "$MIN;";
print OUT_FILE "$MAX;";
print OUT_FILE "$CLOPT\n";

		}
	}
	close(FILE);
	close(OUT_FILE);
}

#&make_data_file('../ubbshm_dev');
&make_data_file('./ubbshm_dev', './ubbshm.dat');
